package wymiana.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
import org.hibernate.annotations.Type;

@Entity
@Table(name = "photo")
public class Photo extends BaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(updatable = false, name = "PHOTO_ID")
	private Integer idPhoto;

	@Column(name = "photo", nullable = true)
	@Lob
	private byte[] photo;

	@Type(type = "org.hibernate.type.NumericBooleanType")
	@Column(updatable = true)
	private Boolean mainPhoto;

	@ManyToOne
	@JoinColumn(name = "school", nullable = true)
	private School school;

	@ManyToOne
	@JoinColumn(name = "user", nullable = true)
	private User user;

	public Photo() {
	}

	public Photo(byte[] photo, Boolean mainphoto) {
		this.photo = photo;
		this.mainPhoto = Boolean.valueOf(false);
	}

	public Integer getIdPhoto() {
		return this.idPhoto;
	}

	public void setIdPhoto(Integer idPhoto) {
		this.idPhoto = idPhoto;
	}

	public byte[] getPhoto() {
		return this.photo;
	}

	public void setPhoto(byte[] photo) {
		this.photo = photo;
	}

	public Boolean getMainPhoto() {
		return this.mainPhoto;
	}

	public void setMainPhoto(Boolean mainPhoto) {
		this.mainPhoto = mainPhoto;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public School getSchool() {
		return school;
	}

	public void setSchool(School school) {
		this.school = school;
	}

}
